In [1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
app = pd.read_pickle('/Users/krystal/Desktop/app_clean.p')
app.head()
Out[2]:
In [ ]:
app = app.drop_duplicates()
In [4]:
app['overall reviews'] = map(lambda x: int(x) if x!='' else np.nan, app['overall reviews'])
app['overall rating'] = map(lambda x: float(x) if x!='' else np.nan, app['overall rating'])
app['current rating'] = map(lambda x: float(x) if x!='' else np.nan, app['current rating'])
Question 4 Do multiple languages influent the reviews of apps?
In [84]:
multi_language = app.loc[app['multiple languages'] == 'Y']
sin_language = app.loc[app['multiple languages'] == 'N']
multi_language['overall rating'].plot(kind = "density")
sin_language['overall rating'].plot(kind = "density")
plt.xlabel('Overall Rating')
plt.legend(labels = ['multiple languages','single language'], loc='upper right')
plt.title('Distribution of overall rating among apps with multiple/single languages')
plt.show()
First, the data set is splitted into two parts, one is app with multiple languages and another is app with single language. Then the density plots for the two subsets are made and from the plots we can see that the overall rating of apps with multiple languages is generally higher than the overall rating of apps with single language. Some specific tests are still needed to perform.
In [10]:
import scipy.stats
In [85]:
multi_language = list(multi_language['overall rating'])
sin_language = list(sin_language['overall rating'])
In [86]:
multiple = []
single = []
for each in multi_language:
if each > 0:
multiple.append(each)
for each in sin_language:
if each > 0:
single.append(each)
In [97]:
print(np.mean(multiple))
print(np.mean(single))
In [90]:
scipy.stats.ttest_ind(multiple, single, equal_var = False)
Out[90]:
I perform t test here. We have two samples here, one is apps with multiple languages and another is apps with single language. So I want to test whether the mean overall rating for these two samples are different.
The null hypothesis is mean overall rating for apps with multiple languages and mean overall rating for apps with single language are the same and the alternative hypothesis is that the mean overall rating for these two samples are not the same.
From the result we can see that the p value is 1.7812330368645647e-26, which is smaller than 0.05, so we should reject null hypothesis at significance level 0.05, that is, we should conclude that the mean of overall rating for these two samples are not the same and multiple languages do influent the rating of an app.
In [98]:
scipy.stats.f_oneway(multiple, single)
Out[98]:
I also perform one-way ANOVA test here.
The null hypothesis is mean overall rating for apps with multiple languages and mean overall rating for apps with single language are the same and the alternative hypothesis is that the mean overall rating for these two samples are not the same.
From the result we can see that the p value is 3.0259308024434954e-26, which is smaller than 0.05, so we should reject null hypothesis at significance level 0.05, that is, we should conclude that the mean of overall rating for these two samples are not the same and multiple languages do influent the rating of an app.
In [99]:
scipy.stats.kruskal(multiple, single)
Out[99]:
I perform Kruskal-Wallis H-test here, which is a non-parametric version of ANOVA. Since t test and one-way ANOVA test all need assumption that the samples shoule come from a normally distributed population, here we use this test, which do not need these assumptions but will lose some power.
The null hypothesis is mean overall rating for apps with multiple languages and mean overall rating for apps with single language are the same and the alternative hypothesis is that the mean overall rating for these two samples are not the same.
From the result we can see that the p value is 3.9085109588433391e-25, which is smaller than 0.05, so we should reject null hypothesis at significance level 0.05, that is, we should conclude that the mean of overall rating for these two samples are not the same and multiple languages do influent the rating of an app.
In general, from the results in these three tests, we can conclude that whether providing multiple languages can influent the rating of an app and the association needs further exploration.
In [ ]: